<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>修改页面</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/statics/component/pear/css/pear.css" />
	</head>
	<body>
<%--	${pageContext.request.contextPath}/user/update--%>
		<form class="layui-form" action="" method="post">
			<div class="mainBox">
				<div class="main-container">
					<div class="layui-form-item">
						<label class="layui-form-label">id</label>
						<div class="layui-input-block">
							<input type="text" name="menuId"  value="${requestScope.sysMenu.menuId}" lay-verify="title" autocomplete="off"
								   placeholder="请输入Id" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">菜单名称</label>
						<div class="layui-input-block">
							<input type="text" name="menuName"  value="${requestScope.sysMenu.menuName}" lay-verify="title" autocomplete="off"
								placeholder="请输入标题" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">父级Id</label>
						<div class="layui-input-block">
							<input type="text" name="parentId"  value="${requestScope.sysMenu.parentId}" lay-verify="title" autocomplete="off"
								   placeholder="请输入标题" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">请求地址</label>
						<div class="layui-input-block">
							<input type="text" name="url" value="${requestScope.sysMenu.url}" lay-verify="title" autocomplete="off" placeholder="请输入标题"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">打开方式:</label>
						<div class="layui-input-block">
							<input type="radio" name="target" value="menuItem" ${requestScope.sysMenu.target.equals("menuItem") ? "checked" : ""} title="页签" >
							<input type="radio" name="target" value="menuBlank" ${requestScope.sysMenu.target.equals("menuBlank") ? "checked" : ""} title="新窗口">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">菜单类型</label>
						<div class="layui-input-block">
							<input type="text" name="menuType" value="${requestScope.sysMenu.menuType}" lay-verify="title" autocomplete="off"
								placeholder="请输入标题" class="layui-input">
						</div>
					</div>
				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="menu-save">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>
		</form>
		<script src="${pageContext.request.contextPath}/statics/component/layui/layui.js"></script>
		<script src="${pageContext.request.contextPath}/statics/component/pear/pear.js"></script>
		<script>
			layui.use(['form', 'jquery'], function() {
				let form = layui.form;
				let $ = layui.jquery;

				form.on('submit(menu-save)', function(data) {
					$.ajax({
						url: '${pageContext.request.contextPath}/update',
						data: data.field,
						dataType: 'json',
						// contentType: 'application/json',
						type: 'post',
						success: function(result) {
							if (result = 1) {
								layer.msg(result.msg, {
									icon: 1,
									time: 1000
								}, function() {
									parent.layer.close(parent.layer.getFrameIndex(window
										.name)); //关闭当前页
									parent.layui.table.reload("menu-table");
								});
							} else {
								layer.msg(result.msg, {
									icon: 2,
									time: 1000
								});
							}
						}
					})
					return false;
				});
			})
		</script>
		<script>
		</script>
	</body>
</html>
